import 'package:flutter/foundation.dart';
import 'package:sqflite_common/sqlite_api.dart';

import 'EJ_EntityBase.dart';

// import 'EJ_EntityBase.dart';

///创建my ticket功能使用的数据库操作类，
class MyTicketEntity extends EJ_EntityBase {
  ///单例
  static MyTicketEntity? _ins;
  MyTicketEntity._();
  static MyTicketEntity instan() {
    if (_ins == null) {
      debugPrint("实例化");
    }
    return _ins ??= MyTicketEntity._();
  }

  @override
  String tableName = "myTickets";

  @override
  Future<void> onCreate(Database db, int version) async {
    debugPrint("创建 $tableName 数据表");
    await db.execute(
        "CREATE TABLE $tableName (id INTEGER PRIMARY KEY, name TEXT, time INTEGER, numbers TEXT)");
  }

  ///当数据库升级时,基类会触发的函数
  @override
  onUpgrade(db, oldVersion, newVersion) {}

  ///当数据库降级,基类会触发的函数
  @override
  onDowngrade(db, oldVersion, newVersion) {}
}
